import requests
from bs4 import BeautifulSoup
import re

url = 'https://ggzyjy.sc.gov.cn/cyzdxm/019002/019002002/20221110/8a69ce88845d0ce301846087352e087eCY.html'
response = requests.get(url)

soup = BeautifulSoup(response.content, 'html.parser')

# 提取项目编号
project_number = soup.find('h4').text.split('：')[1]
print('项目编号:', project_number)

# 提取项目名称
project_name = soup.find_all('h4')[1].text.split('：')[1]
print('项目名称:', project_name)

# 提取合同包信息
contract_packages = soup.find_all('div', class_='con-body')

for package in contract_packages:
    package_name = package.find('h4').text
    package_content = package.find('div', class_='innercontent')

    # 提取供应商信息
    supplier_info = package_content.find_all('div', class_='supplierInfo')
    for supplier in supplier_info:
        supplier_name = supplier.find('span', class_='supplierName').text
        supplier_address = supplier.find('span', class_='supplierAddress').text
        print('供应商信息:')
        print('名称:', supplier_name)
        print('地址:', supplier_address)

    print('\n')  
# contract_info = soup.find('p', class_='u-content').text
# supplier_name = soup.find('td').text
# supplier_address = soup.find_all('td')[1].text
# print('合同包信息:', contract_info)
# print('供应商名称:', supplier_name)
# print('供应商地址:', supplier_address)

# 提取采购人信息
purchaser_name = soup.find('span',
                           class_='noticePurchase-purchaserOrgName').text
purchaser_address = soup.find('span',
                              class_='noticePurchase-purchaserOrgAddress').text
purchaser_contact = soup.find('span',
                              class_='noticePurchase-purchaserLinkTel').text

print('采购人信息:')
print('名称:', purchaser_name)
print('地址:', purchaser_address)
print('联系方式:', purchaser_contact)
